module Epic
	module Command
		class Execute < Blather::Stanza::Iq::Command

			def self.create
				node = self.new
				node.node = 'execute'
				node
			end


			def reply!
				super
				## we have to get the type onnce, then remove the existing form and then set
				## whatever we want to return
				ft = form.type
				remove_form
				if ft.nil?
					f = Blather::XMPPNode::Form.new
					field = Blather::XMPPNode::Field.create(:type => :'text-single', :label => 'command', :var => 'cmd')
					f.type = :form
					f << field
					command << f
					self.status = :executing
				end
				if ft == :submit
					f = Blather::XMPPNode::Form.new
					field = Blather::XMPPNode::Field.create(:type => :fixed, :label => 'output', :var => 'out')
					field.value = 'asdf'
					f << field
					f.type = :result
					command << f
					self.status = :completed
				end

				self
			end
		end
	end
end
